package org.hdl.anima.message;

import java.io.IOException;

import org.hdl.anima.common.io.InputArchive;
import org.hdl.anima.common.io.OutputArchive;

/**
 * 
 * @author qiuhd
 * @since  2014-2-19
 * @version V1.0.0
 */
public abstract class Push implements IPush{
	
	private int id ;
	
	private boolean encrypted = false;
	
	public Push() {
		
	}
	
	public Push(int id) {
		this.id = id;
	}

	public void serialize(OutputArchive archive) throws IOException {
		archive.writeInt(id);
		doSerialize(archive);
	}
	
	@Override
	public void deserialize(InputArchive archive) throws IOException {
		doDeserialize(archive);
	}
	
	public abstract void doSerialize(OutputArchive out) throws IOException;
	
	public abstract void doDeserialize(InputArchive in) throws IOException;
	
	@Override
	public void setId(int id) {
		this.id = id;
	}

	@Override
	public int getId() {
		return this.id;
	}
	
	@Override
	public boolean isEncrypted() {
		return this.encrypted;
	}

	@Override
	public void setEncrypted(boolean encrypted) {
		this.encrypted = encrypted;
	}
}

